"use strict";
cc._RF.push(module, '0308d7WAyJDxq8vvELQmUAN', 'ConfigService');
// scripts/Game/Services/ConfigService.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameMode_json_1 = require("../../engines/managers/gameContent/gameMode_json");
var ServicesBase_1 = require("../Base/ServicesBase");
var ConfigService = /** @class */ (function (_super) {
    __extends(ConfigService, _super);
    function ConfigService() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.serviceName = "===配置表服务";
        _this.m_sourceList = null; // 所有配置表的列表
        _this.m_newestList = null; // 最新关卡模式配置表的列表
        _this.m_shenqiList = null; // 神奇汉字模式配置表的列表
        _this.m_wangengList = null; // 玩梗消除模式配置表的列表
        _this.m_lianxianList = null; // 连线达人模式配置表的列表
        _this.m_normalLevelList = [];
        _this.m_newestLevelList = [];
        _this.m_shenqiLevelList = [];
        _this.m_wangengLevelList = [];
        _this.m_lianxianLevelList = [];
        _this.m_levelSoureList = null; // 各模式关卡的配置表列表,用以给关卡系统初始化
        _this.m_newestMSLevelList = null; // 最新关卡模式关卡的配置表列表,用以给关卡系统初始化
        _this.m_shenqiMSLevelList = null; // 神奇汉字模式关卡的配置表列表,用以给关卡系统初始化
        _this.m_wangengMSLevelList = null; // 玩梗消除模式关卡的配置表列表,用以给关卡系统初始化
        _this.m_lianxianMSLevelList = null; // 连线达人模式关卡的配置表列表,用以给关卡系统初始化
        _this.m_normalGuideList = null;
        //TODO 新模式请看这里
        _this.m_modeImgMap = {};
        _this.m_skinMap = {};
        _this.m_appleSnakeMap = {};
        return _this;
    }
    Object.defineProperty(ConfigService.prototype, "NormalLevelList", {
        get: function () {
            return this.m_normalLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "NewestLevelList", {
        get: function () {
            return this.m_newestLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "ShenqiLevelList", {
        get: function () {
            return this.m_shenqiLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "WanGengLevelList", {
        get: function () {
            return this.m_wangengLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "LianXianLevelList", {
        get: function () {
            return this.m_lianxianLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "LevelSourceList", {
        get: function () {
            return this.m_levelSoureList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "NewestMSLevelSourceList", {
        get: function () {
            return this.m_newestMSLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "ShenqiMSLevelSourceList", {
        get: function () {
            return this.m_shenqiMSLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "WangengMSLevelSourceList", {
        get: function () {
            return this.m_wangengMSLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "LianxianMSLevelSourceList", {
        get: function () {
            return this.m_lianxianMSLevelList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "NormalGuideList", {
        get: function () {
            return this.m_normalGuideList;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "ModeImgMap", {
        get: function () {
            return this.m_modeImgMap;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConfigService.prototype, "SkinMap", {
        get: function () {
            return this.m_skinMap;
        },
        enumerable: false,
        configurable: true
    });
    ConfigService.prototype.GetSkin = function (id) {
        return this.m_skinMap[id];
    };
    Object.defineProperty(ConfigService.prototype, "AppleSnakeMap", {
        get: function () {
            return this.m_appleSnakeMap;
        },
        enumerable: false,
        configurable: true
    });
    ConfigService.prototype.GetAppleSnakeLevel = function (id) {
        return this.m_appleSnakeMap[id];
    };
    ConfigService.prototype.ServiceInit = function () {
        return __awaiter(this, void 0, Promise, function () {
            var array, index, element, arrayNewest, index, element, arrayShenQi, index, element, arrayWanGeng, index, element, arrayLianXian, index, element;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _super.prototype.ServiceInit.call(this);
                        /** 配置默认模式 */
                        this.m_sourceList = [
                            { path: "Json/NormalLevelConfig", responName: "m_normalLevelList" },
                        ];
                        this.m_levelSoureList = [
                            { mode: gameMode_json_1.GAME_MODE.NORMAL, responName: "NormalLevelList" },
                        ];
                        array = this.m_sourceList;
                        index = 0;
                        _a.label = 1;
                    case 1:
                        if (!(index < array.length)) return [3 /*break*/, 4];
                        element = array[index];
                        return [4 /*yield*/, this.LoadFun(element.path, element.responName)];
                    case 2:
                        _a.sent();
                        _a.label = 3;
                    case 3:
                        index++;
                        return [3 /*break*/, 1];
                    case 4:
                        /** 配置最新关卡 */
                        this.m_newestList = [
                            { path: "Json/NormalNewestLevelConfig", responName: "m_newestLevelList" }
                        ];
                        this.m_newestMSLevelList = [
                            { mode: gameMode_json_1.GAME_MODE.CARD_COMPOSITION, responName: "NewestLevelList" },
                        ];
                        arrayNewest = this.m_newestList;
                        index = 0;
                        _a.label = 5;
                    case 5:
                        if (!(index < arrayNewest.length)) return [3 /*break*/, 8];
                        element = arrayNewest[index];
                        return [4 /*yield*/, this.LoadFun(element.path, element.responName)];
                    case 6:
                        _a.sent();
                        _a.label = 7;
                    case 7:
                        index++;
                        return [3 /*break*/, 5];
                    case 8:
                        /** 配置神奇汉字 */
                        this.m_shenqiList = [
                            { path: "Json/NormalShenQiLevelConfig", responName: "m_shenqiLevelList" }
                        ];
                        this.m_shenqiMSLevelList = [
                            { mode: gameMode_json_1.GAME_MODE.SHENQIHANZI, responName: "ShenqiLevelList" },
                        ];
                        arrayShenQi = this.m_shenqiList;
                        index = 0;
                        _a.label = 9;
                    case 9:
                        if (!(index < arrayShenQi.length)) return [3 /*break*/, 12];
                        element = arrayShenQi[index];
                        return [4 /*yield*/, this.LoadFun(element.path, element.responName)];
                    case 10:
                        _a.sent();
                        _a.label = 11;
                    case 11:
                        index++;
                        return [3 /*break*/, 9];
                    case 12:
                        /** 配置玩梗消除 */
                        this.m_wangengList = [
                            { path: "Json/NormalWanGengLevelConfig", responName: "m_wangengLevelList" }
                        ];
                        this.m_wangengMSLevelList = [
                            { mode: gameMode_json_1.GAME_MODE.WANGENG, responName: "WanGengLevelList" },
                        ];
                        arrayWanGeng = this.m_wangengList;
                        index = 0;
                        _a.label = 13;
                    case 13:
                        if (!(index < arrayWanGeng.length)) return [3 /*break*/, 16];
                        element = arrayWanGeng[index];
                        return [4 /*yield*/, this.LoadFun(element.path, element.responName)];
                    case 14:
                        _a.sent();
                        _a.label = 15;
                    case 15:
                        index++;
                        return [3 /*break*/, 13];
                    case 16:
                        /** 配置连线达人 */
                        this.m_lianxianList = [
                            { path: "Json/NormalLianxianLevelConfig", responName: "m_lianxianLevelList" }
                        ];
                        this.m_lianxianMSLevelList = [
                            { mode: gameMode_json_1.GAME_MODE.LIANXIAN, responName: "LianXianLevelList" },
                        ];
                        arrayLianXian = this.m_lianxianList;
                        index = 0;
                        _a.label = 17;
                    case 17:
                        if (!(index < arrayLianXian.length)) return [3 /*break*/, 20];
                        element = arrayLianXian[index];
                        return [4 /*yield*/, this.LoadFun(element.path, element.responName)];
                    case 18:
                        _a.sent();
                        _a.label = 19;
                    case 19:
                        index++;
                        return [3 /*break*/, 17];
                    case 20: return [2 /*return*/];
                }
            });
        });
    };
    ConfigService.prototype.LoadFun = function (path, responName) {
        return __awaiter(this, void 0, void 0, function () {
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
                            cc.resources.load(path, function (err, asset) {
                                if (err) {
                                    reject(err);
                                    console.error("\u52A0\u8F7D\u914D\u7F6E" + path + "\u5931\u8D25", err);
                                    return;
                                }
                                _this[responName] = asset.json;
                                //this.Log("##",responName,this[responName]);
                                resolve();
                            });
                        })];
                    case 1:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    return ConfigService;
}(ServicesBase_1.default));
exports.default = ConfigService;

cc._RF.pop();